package com.zhuoyue.system.service.impl;

import java.util.List;

import com.zhuoyue.common.annotation.DataSource;

import com.zhuoyue.system.domain.po.TblMessagePo;
import com.zhuoyue.system.domain.vo.TblMessageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhuoyue.system.mapper.TblMessageMapper;
import com.zhuoyue.system.domain.TblMessage;
import com.zhuoyue.system.service.ITblMessageService;

import static com.zhuoyue.common.enums.DataSourceType.SLAVE;

/**
 * 消息Service业务层处理
 *
 * @author hewenze
 * @date 2020-08-13
 */
@Service
public class TblMessageServiceImpl implements ITblMessageService {
    @Autowired
    private TblMessageMapper tblMessageMapper;


    /**
     * 查询消息列表
     *
     * @param tblMessagePo 消息
     * @return 消息
     */
    @Override
    @DataSource(SLAVE)
    public List<TblMessageVo> selectTblMessageList(TblMessagePo tblMessagePo) {
        return tblMessageMapper.selectTblMessageList(tblMessagePo);
    }

    @Override
    public List<TblMessage> selectByTime(String orgCode, String account, String start, String end, Integer pageNum, Integer pageSize) {

        //查询数据库表名
        List<String> tableList = this.tblMessageMapper.selectTableName();

        List<TblMessage> tblSecurityLogs = this.tblMessageMapper.selectByTime(orgCode, account, tableList, start, end, pageNum, pageSize);

        System.out.println(tblSecurityLogs);

        return tblSecurityLogs;
    }

    @Override
    public Integer selectByTimeCount(String orgCode, String account, String start, String end) {

        //查询数据库表名
        List<String> tableList = this.tblMessageMapper.selectTableName();


        Integer integer = this.tblMessageMapper.selectByTimeCount(tableList, orgCode, account, start, end);


        return integer;
    }
}
